package com.hotelvip.controller;

import com.hotelvip.common.utils.JSONResult;
import com.hotelvip.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Lzh
 * @date 2021/1/25 9:59
 */
@RestController
@RequestMapping("/Excel")
@Api(basePath = "/Excel",tags = "Excel文件上传下载模块")
public class ExcelController {

    @Autowired
    private FileService fileService;

    @ApiOperation(value = "导入execl",httpMethod = "POST")
    @PostMapping("/uploadUserExcel")
    public JSONResult uploadUserExcel(@RequestParam(value="excelFile",required = false) MultipartFile excelFile){
        fileService.uploadUserExcel(excelFile);
        return JSONResult.ok("文件导入成功");
    }

    @ApiOperation(value = "导出用户excel",httpMethod = "GET")
    @GetMapping("/getUserExcel")
    public void getUserExcel( HttpServletResponse response) throws IOException {
        fileService.getUserExcel(response);
        return;
    }


//    @ApiOperation(value = "会员excel",httpMethod = "GET")
//    @GetMapping("/vipExcel")
//    public void vipExcel( HttpServletResponse response) throws IOException {
//        fileService.getVipExcel(response);
//        return;
//    }

}
